﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="CruxConfigurations">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="ApplicationSettings">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="GeneralSettings">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="ApplicationPath">
                      <xs:complexType>
                        <xs:attribute name="URL" type="xs:string" use="required" />
                      </xs:complexType>
                    </xs:element>

                      <xs:element name="ApplicationTheme">
                          <xs:complexType>
                              <xs:attribute name="Name" type="xs:string" use="required" />
                          </xs:complexType>
                      </xs:element>

                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="DatabaseSettings">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="CruxDB">
                      <xs:complexType>
                        <xs:attribute name="ConnectionString" type="xs:string" use="required" />
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="ApplicationLogDB">
                      <xs:complexType>
                        <xs:attribute name="ConnectionString" type="xs:string" use="required" />
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="AdditionalDatabaseConnections" minOccurs="0" maxOccurs="1">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element maxOccurs="unbounded" name="DatabaseConnection">
                            <xs:complexType>
                              <xs:attribute name="Name" type="xs:string" use="required" />
                              <xs:attribute name=" ConnectionString" type="xs:string" use="required" />
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="WorkflowSettings">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="WorkflowFolder">
                      <xs:complexType>
                        <xs:attribute name="Name" type="xs:string" use="required" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
                </xs:element>
                 <xs:element name="CustomSettings" minOccurs="0" maxOccurs="1">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" minOccurs="0" name="Add">
                      <xs:complexType>
                        <xs:attribute name="Key" type="xs:string" use="required" />
                        <xs:attribute name="Value" type="xs:string" use="required" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              
            </xs:sequence>
          </xs:complexType>
        </xs:element>
          <xs:element name="ApplicationFeatures" minOccurs="0">
              <xs:complexType>
                  <xs:sequence>
                      <xs:element name="Feature" minOccurs="0" maxOccurs="unbounded">
                          <xs:complexType>
                              <xs:attribute name="Name" type="xs:string" use="required" />
                              <xs:attribute name="Enabled" type="xs:string" use="required" />
                          </xs:complexType>
                      </xs:element>
                  </xs:sequence>
              </xs:complexType>
          </xs:element>

          <xs:element name="Notifications">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="EmailNotifications">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="NotificationActions">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="Action" maxOccurs="unbounded">
                            <xs:complexType>
                              <xs:attribute name="Name" type="xs:string" use="required" />
                              <xs:attribute name="Notify" type="xs:string" use="required" />
                              <xs:attribute name="NotificationTemplateFile" type="xs:string" use="required" />
                              <xs:attribute name="MailSubject" type="xs:string" use="required" />
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="Notify" type="xs:string" use="required" />
                  <xs:attribute name="SmtpServer" type="xs:string" use="required" />
                  <xs:attribute name="UserName" type="xs:string" use="required" />
                  <xs:attribute name="Password" type="xs:string" use="required" />
                  <xs:attribute name="TemplateFolder" type="xs:string" use="required" />
                  <xs:attribute name="Port" type="xs:unsignedByte" use="required" />
                  <xs:attribute name="FromAddress" type="xs:string" use="required" />
                  <xs:attribute name="UseSSL" type="xs:string" use="required" />
                  <xs:attribute name="SendInHtml" type="xs:string" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Security">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Providers">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="SecurityProvider">
                      <xs:complexType>
                        <xs:attribute name="Name" type="xs:string" use="required" />
                        <xs:attribute name="Type" type="xs:string" use="required" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="PasswordStorage">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Password">
                      <xs:complexType>
                        <xs:attribute name="StorageType" type="xs:string" use="required" />
                      </xs:complexType>
                    </xs:element>
                      <xs:element name="MasterPassword" minOccurs="0" maxOccurs="1">
                          <xs:complexType>
                              <xs:attribute name="Value" type="xs:string" use="required" />
                          </xs:complexType>
                      </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="FeatureManager">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="FeatureProvider">
                <xs:complexType>
                  <xs:attribute name="Name" type="xs:string" use="required" />
                  <xs:attribute name="Type" type="xs:string" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="PasswordManager">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="PasswordProvider">
                <xs:complexType>
                  <xs:attribute name="Name" type="xs:string" use="required" />
                  <xs:attribute name="Type" type="xs:string" use="required" />
                  <xs:attribute name="ErrorMessage" type="xs:string" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="UserInterface">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Views">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="View">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="Roles">
                            <xs:complexType mixed="true">
                              <xs:sequence minOccurs="0">
                                <xs:element maxOccurs="unbounded" name="Role">
                                  <xs:complexType>
                                    <xs:attribute name="Name" type="xs:string" use="required" />
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                              <xs:attribute name="Condition" type="xs:string" use="required" />
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                        <xs:attribute name="Name" type="xs:string" use="required" />
                        <xs:attribute name="Title" type="xs:string" use="required" />
                        <xs:attribute name="InternalView" type="xs:boolean" use="required" />
                        <xs:attribute name="URL" type="xs:string" use="optional" />
                        <xs:attribute name="Section" type="xs:string" use="optional" />
                        <xs:attribute name="ImageUrl" type="xs:string" use="optional" />
                        <xs:attribute name="DashboardName" type="xs:string" use="optional" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="Dashboards" minOccurs="0" maxOccurs="1">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Dashboard" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="DashboardItems" minOccurs="0" maxOccurs="unbounded">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element minOccurs="0" maxOccurs="unbounded" name="DashboardItem">
                                  <xs:complexType>
                                    <xs:attribute name="Name" type="xs:string" use="required" />
                                    <xs:attribute name="View" type="xs:string" use="required" />
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                        <xs:attribute name="Name" type="xs:string" use="required" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="Navigations">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="Navigation">
                      <xs:complexType>
                        <xs:attribute name="Name" type="xs:string" use="required" />
                        <xs:attribute name="Description" type="xs:string" use="required" />
                        <xs:attribute name="SortOrder" type="xs:unsignedByte" use="required" />
                        <xs:attribute name="ViewName" type="xs:string" use="required" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>


                <xs:element name="GridExtensions" minOccurs="0">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element maxOccurs="unbounded" name="GridExtension">
                                <xs:complexType>
                                    <xs:attribute name="GridName" type="xs:string" use="required" />
                                    <xs:attribute name="ActionLink" type="xs:string" use="required" />
                                    <xs:attribute name="Tooltip" type="xs:string" use="required" />
                                    <xs:attribute name="Image" type="xs:string" use="required" />
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>


                <xs:element name="DefaultView">
                <xs:complexType>
                  <xs:attribute name="ViewName" type="xs:string" use="required" />
                </xs:complexType>
              </xs:element>
              
              <xs:element name="ApplicationFolder" minOccurs="0" maxOccurs="1">
                <xs:complexType>
                  <xs:attribute name="Name" type="xs:string" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
          <xs:element name="ProcessorSettings" minOccurs="0">
              <xs:complexType>
                  <xs:sequence>
                      <xs:element name="processor" maxOccurs="unbounded">
                          <xs:complexType>
                              <xs:attribute name="Name" type="xs:string" use="required" />
                              <xs:attribute name="Assembly" type="xs:string" use="required" />
                              <xs:attribute name="Type" type="xs:string" use="required" />
                          </xs:complexType>
                      </xs:element>
                  </xs:sequence>
              </xs:complexType>
          </xs:element>
          <xs:element name="ExceptionsAndErrors">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Errors">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="Error">
                      <xs:complexType>
                        <xs:attribute name="NameOrCode" type="xs:unsignedShort" use="required" />
                        <xs:attribute name="ShortDescription" type="xs:string" use="required" />
                        <xs:attribute name="Description" type="xs:string" use="required" />
                        <xs:attribute name="ProbableCause" type="xs:string" use="required" />
                        <xs:attribute name="RecommendedAction" type="xs:string" use="required" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>